package com.example.myapp;

import androidx.appcompat.app.AppCompatActivity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

import com.example.myapp.db.MyHelper;

public class MainActivity extends AppCompatActivity {

    private Button button;
    private EditText usernameEd;
    private EditText passwordEd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MyHelper myHelper = new MyHelper(MainActivity.this);
        SQLiteDatabase database = myHelper.getWritableDatabase();
        initView();
        initData();
        initEvent();
    }

    //视图
    public void initView() {
        usernameEd = findViewById(R.id.username_ed);
        passwordEd = findViewById(R.id.password_ed);
        button = findViewById(R.id.zhuce_ed);

    }

    //数据
    public void initData() {
        MyDataUtil myDataUntil = new MyDataUtil();
        myDataUntil.insertData(MainActivity.this, "尹琦", "202065110422");
        myDataUntil.updateData(MainActivity.this, "admin", "123456");
    }

    //事件
    public void initEvent() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                initData();
            }
        });
    }
}